cmake_minimum_required(VERSION 2.8)

set(APPNAME demo)

project(${APPNAME})

find_package(gflags REQUIRED)
find_package(Boost REQUIRED COMPONENTS system thread filesystem)

set(ENV{PKG_CONFIG_PATH} /usr/lib/pkgconfig)
find_package(PkgConfig)
pkg_search_module(PROTOBUF REQUIRED protobuf)
pkg_search_module(GRPC REQUIRED grpc)

SET(CMAKE_BUILD_TYPE "Debug")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -pthread -g -Wl,-rpath=./lib")

include_directories(app 
    ${Boost_INCLUDE_DIRS})

# add current directory to DIRSRCS
aux_source_directory(. DIRSRCS)
# add app derectories to APP_FILE_LIST
file(GLOB_RECURSE APP_FILE_LIST ${CMAKE_CURRENT_SOURCE_DIR}/app/*.c*)

# generate application
add_executable(${APPNAME}
    ${DIRSRCS}
    ${APP_FILE_LIST}
    )

# link library to application
target_link_libraries(${APPNAME}
    /usr/lib/libsnap7.so
    gflags 
    glog
    ${Boost_LIBRARIES}
    protobuf
    grpc++
    grpc++_reflection)